<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>关闭套接字接收或发送，或两者都关闭</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.socket-setopt.html">« socket_setopt</a></li>
      <li style="float: right;"><a href="function.socket-strerror.html">socket_strerror »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.sockets.html">Socket 函数</a></li>
    <li>关闭套接字接收或发送，或两者都关闭</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.socket-shutdown" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">socket_shutdown</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">socket_shutdown</span> &mdash; <span class="dc-title">关闭套接字接收或发送，或两者都关闭</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.socket-shutdown-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>socket_shutdown</strong></span>(<span class="methodparam"><span class="type"><a href="class.socket.html" class="type Socket">Socket</a></span> <code class="parameter">$socket</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = 2</span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>socket_shutdown()</strong></span> 函数允许通过 <code class="parameter">socket</code> 停止接收、发送或所有数据（默认）。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    关联的一个或多个缓冲区可能会清空，也可能不会。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-shutdown-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">socket</code></dt>

     <dd>

      <p class="para">
       从 <span class="function"><a href="function.socket-create.html" class="function">socket_create()</a></span> 创建的 <span class="classname"><a href="class.socket.html" class="classname">Socket</a></span> 实例。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">mode</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">mode</code> 的值可以是以下之一：
       <table class="doctable table">
        <caption><strong><code class="parameter">mode</code> 可用值</strong></caption>
        
         <tbody class="tbody">
          <tr>
           <td><code class="literal">0</code></td>
           <td>
            关闭套接字读
           </td>
          </tr>

          <tr>
           <td><code class="literal">1</code></td>
           <td>
            关闭套接字写
           </td>
          </tr>

          <tr>
           <td><code class="literal">2</code></td>
           <td>
            关闭套接字读和写
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-shutdown-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.socket-shutdown-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
  <td>8.0.0</td>
  <td>
   现在 <code class="parameter">socket</code> 是 <span class="classname"><a href="class.socket.html" class="classname">Socket</a></span> 实例，
   之前是 <span class="type">resource</span>。
  </td>
 </tr>

    </tbody>
   
  </table>

 </div>

</div></div></div></body></html>